﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;

public partial class ApproalUpdate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitData();
        }
    }

    //初始化数据
    void InitData()
    {
        using (DataClassesDataContext dc = new DataClassesDataContext())
        {
            var app = dc.Approal.Select(a => a).Where(a => a.ID == Request.QueryString["AID"]).SingleOrDefault();
            txtAppNum.Text = app.Approal_ID.ToString();
            txtAppTitle.Text = app.Approal_Title.ToString();
            txtAppSum.Text = app.Approal_Summary.ToString();
            txtAppDate.Text = app.Approal_Date.ToString();
            cmbDis.Value = app.ComminityID.ToString();
        }
    }
    //数据更新
    void UpdateData()
    {
        using (DataClassesDataContext dc = new DataClassesDataContext())
        {
            var app = dc.Approal.Select(a => a).Where(a => a.ID == Request.QueryString["AID"]).SingleOrDefault();
            app.Approal_ID = txtAppNum.Text.ToString();
            app.Approal_Title = txtAppTitle.Text.ToString();
            app.Approal_Summary = txtAppSum.Text.ToString();
            app.Approal_Date = txtAppDate.Text.ToString();
            app.ComminityID = cmbDis.Value.ToString();
            dc.SubmitChanges();
            Frame.Global.GlobalFunctions.AlertToUrl("批文信息修改成功！", "ApproalManager.aspx");
        }
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        UpdateData();
    }
    protected void btnEsc_Click(object sender, EventArgs e)
    {
        Response.Redirect("ApproalManager.aspx");
    }
}